home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Graphics / QuickDraw GX / GX->PostScript Sample / GXToPostScript / PostScriptFiles / GlyphShapeProcs.ps < prev    next >
Encoding:
Text File  |  2000-09-28  |  5.4 KB  |  203 lines  |  [TEXT/MPS ]

  1. %
  2. %    File:        GlyphShapeProcs.ps
  3. %
  4. %    Contains:    Procedures needed to render glyph shapes
  5. %
  6. %    Version:    Technology:    Quickdraw GX 1.1.x.
  7. %
  8. %    Copyright:    © 1991-7 by Apple Computer, Inc., all rights reserved.
  9. %
  10. %
  11.  
  12. %
  13. %        Define a kshow for type-0 fonts on printers that are type-0 aware.  type-0 aware
  14. %        is determined by the cshow operator being present.
  15. %        If only Adobe had bothered to ensure that all text operators (including kshow) worked properly
  16. %        with composite fonts, then this wouldn't be necessary.  The fact that I'm able to define
  17. %        my own proves that there was no excuse for Adobe to have left this out.
  18. %
  19. /GXkshow /kshow load def                            % Start kshow out to be the real kshow.
  20. /cshow where {pop} {save} ifelse            % Redefine GXkshow if cshow is known (implying composite font capable)
  21.  
  22.     /type0String null def
  23.     /type0Char 1 string def
  24.     /type0firstChar true def
  25.     /GXkshow {
  26.     
  27.         currentfont /FontType get 0 ne {
  28.         
  29.             kshow
  30.             
  31.         } {
  32.             
  33.             /type0String Xstore
  34.             /kshowProc Xstore
  35.             /type0firstChar true store
  36.             
  37.             % Procedure passed to cshow will call the kshow procedure (except first time) and then draw the glyph
  38.             
  39.             { 
  40.                 pop pop                                                    % We don't care about the advance vector.
  41.                 type0Char exch 0 exch put                % Save the character in a 1 byte string.
  42.                 type0firstChar {                                % If it's the first character, do nothing but toggle flag.
  43.                     /type0firstChar false store
  44.                 } {                                                            % else execute the kshow procedure before drawing glyph.
  45.                     -1 -1 kshowProc                                % Call kshow proc, but push bogus character codes on stack
  46.                 } ifelse
  47.     
  48.                 type0Char show                                    % Show the character
  49.                 
  50.             } type0String cshow
  51.             
  52.         } ifelse
  53.         
  54.     } bind def
  55.  
  56. /cshow where {pop} {restore} ifelse                % Restore away definitions if cshow wasn't known.
  57.  
  58.  
  59. %<FF>
  60. %
  61. %    Procedure KshowAbsPos:
  62. %
  63. %        Procedure is passed to kshow to render a glyph group that
  64. %        specifies absolute positions for each glyph.
  65. %        The current point is expected to be in the position of the first glyph.
  66. %
  67. %    Stack should be before the kshow operation:
  68. %        xN yN xN-1 yN-1…… x2 y2
  69. %
  70. /KshowAbsPos {
  71.  
  72.     pop pop                        %                We don't care about the kerning pair.
  73.     moveto                        %                move to the next point on the stack.
  74.  
  75. } Bdef
  76.  
  77.  
  78.  
  79. %
  80. %    Procedure KshowAbsPosH:
  81. %
  82. %        Procedure is passed to kshow to render a glyph group that
  83. %        specifies absolute positions for each glyph but all share the same Y.
  84. %        The current point is expected to be in the position of the first glyph.
  85. %
  86. %    Stack should be before the kshow operation:
  87. %        xN xN-1…… x2 Y
  88. %
  89. /KshowAbsPosH {
  90.  
  91.     pop pop                                        % We don't care about the kerning pair.
  92.     dup                                                % Make a duplicate of the Y value.
  93.     3 1 roll                                    % Move it behind the next X value.
  94.     moveto                                        % Move to the position.
  95.     
  96. } Bdef
  97.  
  98.  
  99. %
  100. %    Procedure KshowAbsPosV:
  101. %
  102. %        Procedure is passed to kshow to render a glyph group that
  103. %        specifies absolute positions for each glyph but all share the same X.
  104. %        The current point is expected to be in the position of the first glyph.
  105. %
  106. %    Stack should be before the kshow operation:
  107. %        yN yN-1…… y2 X
  108. %
  109. /KshowAbsPosV {
  110.  
  111.     pop pop                                        % We don't care about the kerning pair.
  112.     dup                                                % Make a duplicate of the X value.
  113.     3 1 roll                                    % Move it behind the next Y value.
  114.     exch                                            % Top of stack was Y X
  115.     moveto                                        % Move to the position.
  116.     
  117. } Bdef
  118.  
  119.  
  120. %
  121. %    Procedure KshowDelta:
  122. %
  123. %        Procedure is passed to kshow to render a glyph group that
  124. %        specifies deltas for each glyph.
  125. %        The current point is expected to be in the position of the first glyph.
  126. %
  127. %    Stack should be before the kshow operation:
  128. %        xN yN xN-1 yN-1…… x2 y2
  129. %
  130. /KshowDelta {
  131.  
  132.     pop pop                        %    We don't care about the kerning pair.
  133.     rmoveto                        % Add the delta.
  134.  
  135. } Bdef
  136.  
  137.  
  138.  
  139. %
  140. %    Procedure KshowDeltaH:
  141. %
  142. %        Procedure is passed to kshow to render a glyph group that
  143. %        specifies absolute positions for each glyph but all share the same Y.
  144. %        The current point is expected to be in the position of the first glyph.
  145. %
  146. %    Stack should be before the kshow operation:
  147. %        xN xN-1…… x2 Y
  148. %
  149. /KshowDeltaH {
  150.  
  151.     pop pop                                        % We don't care about the kerning pair.
  152.     dup                                                % Make a duplicate of the Y value.
  153.     3 1 roll                                    % Move it behind the next X value.
  154.     rmoveto                                        % Add the delta.
  155.     
  156. } Bdef
  157.  
  158.  
  159. %
  160. %    Procedure KshowDeltaV:
  161. %
  162. %        Procedure is passed to kshow to render a glyph group that
  163. %        specifies absolute positions for each glyph but all share the same X.
  164. %        The current point is expected to be in the position of the first glyph.
  165. %
  166. %    Stack should be before the kshow operation:
  167. %        yN yN-1…… y2 X
  168. %
  169. /KshowDeltaV {
  170.  
  171.     pop pop                                        % We don't care about the kerning pair.
  172.     dup                                                % Make a duplicate of the X value.
  173.     3 1 roll                                    % Move it behind the next Y value.
  174.     exch                                            % Top of stack was Y X
  175.     rmoveto                                        % Add the delta.
  176.     
  177. } Bdef
  178.  
  179.  
  180.  
  181. %
  182. %    Procedure CnstDltShw:
  183. %
  184. %        Procedure used to display a run of glyphs That had
  185. %            advance bits of all zero but a constant delta value
  186. %        Note, an rmoveto by the advance must be emitted by Imaging
  187. %        Engine prior to doing this operation for proper results.
  188. %        It is assumed that the current point is where the first
  189. %        character is to draw.
  190. %
  191. %            Ax Ay string CnstDltShw -
  192. %
  193. /CnstDltShw {
  194.  
  195.     3 1 roll                                % Make stack: string Ax Ay
  196.     2 copy                                    % Save a copy of Ax Ay for later so we can fix the current position.
  197.     5 -1 roll                                % Make Stack: Ax Ay Ax Ay string
  198.     ashow                                        % Do the ashow, stack is left Ax Ay
  199.     neg exch neg exch                % Stack is now: -Ax -Ay
  200.     rmoveto                                    % Undo the addition of Ax Ay to the advance of the last glyph in the run.
  201.  
  202. } Bdef
  203.